<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>DOM事件监听程序</title>
</head>
<body>
<h1>向 Window 对象添加事件处理程序</h1>
<p>在 window 对象上使用 addEventListener() 方法。</p>
<p id="demo"></p>
<script>
  window.addEventListener("resize", function(){
    document.getElementById("demo").innerHTML = Math.random();
  });
</script>
</body>
</html>